package com.teziyou.commodity.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.teziyou.commodity.logic.ShelfLogic;
import com.teziyou.commodity.logic.TicketLogic;

@SuppressWarnings("rawtypes")
@RequestMapping("/shelf")
@Controller
public class ShelfController extends BaseController {
	
	@Autowired
	private TicketLogic ticketLogic;
	
	@Autowired
	private ShelfLogic shelfLogic;
	
	@RequestMapping("/index")
	public String index(HttpServletRequest req) {
		List list = ticketLogic.listTickets(super.getParaMap(req));
		req.setAttribute("tickets", list);
		return "shelf/index";
	}
	
	@RequestMapping("/loadticket")
	public String loadTicket(HttpServletRequest req) {
		long ticketId = Long.parseLong(req.getParameter("id"));
		Map ticket = shelfLogic.loadTicket(ticketId);
		req.setAttribute("ticket", ticket);
		return "shelf/shelf";
	}
	
	@RequestMapping("/relatedtickets")
	public String relatedTickets() {
		return null;
	}
	
	@RequestMapping("/relatedlines")
	public String relatedLines() {
		return null;
	}
	
	@RequestMapping("/list")
	public String list(HttpServletRequest req) {
		List list = ticketLogic.listTickets(super.getParaMap(req));
		req.setAttribute("tickets", list);
		return "shelf/list";
	}
	
	@RequestMapping("/addview")
	public String jumpAdd() {
		return "shelf/add";
	}
	
	@RequestMapping("/ticket")
	public String jumpTicket(HttpServletRequest req) {
		List list = ticketLogic.listTickets(super.getParaMap(req));
		req.setAttribute("tickets", list);
		return "shelf/ticket";
	}
	
	@RequestMapping("/loadRelatedTickets")
	public String loadRelatedTickets(HttpServletRequest req) {
		return "shelf/ticket";
	}
	
}
